

package com.hazelcast.jet.pipeline.file.impl;

import com.hazelcast.function.FunctionEx;
import com.hazelcast.jet.pipeline.file.FileFormat;

import javax.annotation.Nonnull;
import java.nio.file.Path;
import java.util.stream.Stream;

/**
 * Provides a mapping function from a {@code Path} to a {@code Stream} of
 * items emitted from a local filesystem source. It is specialized to a
 * single {@link FileFormat}, whose ID you can retrieve from the {@link
 * #format} method.
 */
public interface ReadFileFnProvider {

    /**
     * Takes a {@link FileFormat} and uses it to create and return a function
     * that maps a {@code Path} on the local filesystem to a stream of items
     * that the file source should emit.
     */
    @Nonnull
    <T> FunctionEx<Path, Stream<T>> createReadFileFn(@Nonnull FileFormat<T> format);

    /**
     * Returns a string that identifies the {@link FileFormat} supported by
     * this function provider.
     */
    @Nonnull
    String format();
}
